import React from 'react';
import  Grandpa from './components/Grandpa'
import  MyContext from './Mycontext'
const {Provider} = MyContext

class App extends React.Component{
  constructor(props){
    super(props)
    this.state={
      message:"welcome",
      items:[
        {id:"111",name:"电脑"},
        {id:"222",name:"手机"}
      ]
    }
  }
  changeMsg(){
     this.setState({
      message:"welcome to wuhan",
     })
  }

  render(){
    let state=this.state
    state.changeMsg=this.changeMsg.bind(this)
    return (
      <div>
      {state.message}
      <button onClick={e=>this.changeMsg()}>改变message</button>
      <Provider value={state}>
        <Grandpa></Grandpa>
      </Provider>
      </div>
    )
  }
}

export default App;
